home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / StatusScrollerBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  13KB  |  378 lines

  1. package symantec.itools.awt.util;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //     09/19/97    RKM    Fixed connection that called deprecated code
  8. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  9.  
  10. /**
  11.  * BeanInfo for StatusScroller.
  12.  *
  13.  */
  14.  
  15. public class StatusScrollerBeanInfo extends SimpleBeanInfo {
  16.  
  17.     /**
  18.      * Constructs a StatusScrollerBeanInfo object.
  19.      */
  20.     public StatusScrollerBeanInfo() {
  21.     }
  22.  
  23.     /**
  24.      * Gets a BeanInfo for the superclass of this bean.
  25.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  26.      */
  27.     public BeanInfo[] getAdditionalBeanInfo() {
  28.         try {
  29.             BeanInfo[] bi = new BeanInfo[1];
  30.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  31.             return bi;
  32.         }
  33.         catch (IntrospectionException e) { throw new Error(e.toString());}
  34.     }
  35.  
  36.     /**
  37.      * Gets the SymantecBeanDescriptor for this bean.
  38.      * @return an object of type SymantecBeanDescriptor
  39.      * @see symantec.itools.beans.SymantecBeanDescriptor
  40.      */
  41.     public BeanDescriptor getBeanDescriptor() {
  42.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  43.         String s=group.getString("GroupAWTAdditions"); 
  44.  
  45.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  46.         bd.setFolder(s);
  47.         bd.setToolbar(s);
  48.         bd.setWinHelp("0x12396");
  49.  
  50.         return (BeanDescriptor) bd;
  51.     }
  52.  
  53.     /**
  54.      * Gets an image that may be used to visually represent this bean
  55.      * (in the toolbar, on a form, etc).
  56.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  57.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  58.      * @return an image for this bean, always color even if requested monochrome
  59.      * @see BeanInfo#ICON_MONO_16x16
  60.      * @see BeanInfo#ICON_COLOR_16x16
  61.      * @see BeanInfo#ICON_MONO_32x32
  62.      * @see BeanInfo#ICON_COLOR_32x32
  63.      */
  64.     public java.awt.Image getIcon(int iconKind) {
  65.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  66.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  67.             java.awt.Image img = loadImage("StatusScrollerC16.gif");
  68.             return img;
  69.         }
  70.  
  71.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  72.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  73.             java.awt.Image img = loadImage("StatusScrollerC32.gif");
  74.             return img;
  75.         }
  76.  
  77.         return null;
  78.     }
  79.  
  80.     /**
  81.      * Gets an array of descriptions of the methods used for "connections" by
  82.      * Visual CafΘ's Interaction Wizard.
  83.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  84.      * @return method descriptions for this bean
  85.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  86.      */
  87.     public MethodDescriptor[] getMethodDescriptors() {
  88.         Class[] args;
  89.         ConnectionDescriptor connection;
  90.         java.util.Vector connections;
  91.         java.util.Vector md = new java.util.Vector();
  92.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  93.  
  94.         try{
  95.             args = null;
  96.             MethodDescriptor isScrollClean = new MethodDescriptor(beanClass.getMethod("isScrollClean", args));
  97.  
  98.             connections = new java.util.Vector();
  99.             connection = new ConnectionDescriptor("output", "boolean", "",
  100.                                     "%name%.isScrollClean()",
  101.                                     conn.getString("isScrollClean"));
  102.             connections.addElement(connection);
  103.  
  104.             isScrollClean.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  105.             md.addElement(isScrollClean);
  106.         } catch (Exception e) { throw new Error("isScrollClean:: " + e.toString()); }
  107.  
  108.         try{
  109.             args = new Class[1];
  110.             args[0] = java.lang.Boolean.TYPE ;
  111.             MethodDescriptor setScrollClean = new MethodDescriptor(beanClass.getMethod("setScrollClean", args));
  112.  
  113.             connections = new java.util.Vector();
  114.             connection = new ConnectionDescriptor("input", "boolean", "",
  115.                                     "%name%.setScrollClean(%arg%);",
  116.                                     conn.getString("setScrollClean"));
  117.             connections.addElement(connection);
  118.  
  119.             setScrollClean.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  120.             md.addElement(setScrollClean);
  121.         } catch (Exception e) { throw new Error("setScrollClean:: " + e.toString()); }
  122.  
  123.         try{
  124.             args = new Class[1];
  125.             args[0] = java.lang.String.class ;
  126.             MethodDescriptor setString = new MethodDescriptor(beanClass.getMethod("setString", args));
  127.  
  128.             connections = new java.util.Vector();
  129.             connection = new ConnectionDescriptor("input", "String", "",
  130.                                     "%name%.setString(%arg%);",
  131.                                     conn.getString("setString"));
  132.             connections.addElement(connection);
  133.  
  134.             setString.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  135.             md.addElement(setString);
  136.         } catch (Exception e) { throw new Error("setString:: " + e.toString()); }
  137.  
  138.         try{
  139.             args = null;
  140.             MethodDescriptor isRightToLeft = new MethodDescriptor(beanClass.getMethod("isRightToLeft", args));
  141.  
  142.             connections = new java.util.Vector();
  143.             connection = new ConnectionDescriptor("output", "boolean", "",
  144.                                     "%name%.isRightToLeft()",
  145.                                     conn.getString("isRightToLeft"));
  146.             connections.addElement(connection);
  147.  
  148.             isRightToLeft.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  149.             md.addElement(isRightToLeft);
  150.         } catch (Exception e) { throw new Error("isRightToLeft:: " + e.toString()); }
  151.  
  152.         try{
  153.             args = new Class[1];
  154.             args[0] = java.lang.Boolean.TYPE ;
  155.             MethodDescriptor setRightToLeft = new MethodDescriptor(beanClass.getMethod("setRightToLeft", args));
  156.  
  157.             connections = new java.util.Vector();
  158.             connection = new ConnectionDescriptor("input", "void", "",
  159.                                     "%name%.setRightToLeft(%name%.isRightToLeft());",
  160.                                     conn.getString("setRightToLeftToggle"));
  161.             connections.addElement(connection);
  162.  
  163.             connection = new ConnectionDescriptor("input", "boolean", "",
  164.                                     "%name%.setRightToLeft(%arg%);",
  165.                                     conn.getString("setRightToLeft"));
  166.             connections.addElement(connection);
  167.  
  168.             setRightToLeft.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  169.             md.addElement(setRightToLeft);
  170.         } catch (Exception e) { throw new Error("setRightToLeft:: " + e.toString()); }
  171.  
  172.         try{
  173.             args = null;
  174.             MethodDescriptor isAutoStart = new MethodDescriptor(beanClass.getMethod("isAutoStart", args));
  175.  
  176.             connections = new java.util.Vector();
  177.             connection = new ConnectionDescriptor("output", "boolean", "",
  178.                                     "%name%.isAutoStart()",
  179.                                     conn.getString("isAutoStart"));
  180.             connections.addElement(connection);
  181.  
  182.             isAutoStart.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  183.             md.addElement(isAutoStart);
  184.         } catch (Exception e) { throw new Error("isAutoStart:: " + e.toString()); }
  185.  
  186.         try{
  187.             args = new Class[1];
  188.             args[0] = java.lang.Integer.TYPE ;
  189.             MethodDescriptor setDelay = new MethodDescriptor(beanClass.getMethod("setDelay", args));
  190.  
  191.             connections = new java.util.Vector();
  192.             connection = new ConnectionDescriptor("input", "int", "",
  193.                                     "%name%.setDelay(%arg%);",
  194.                                     conn.getString("setDelay"));
  195.             connections.addElement(connection);
  196.  
  197.             setDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  198.             md.addElement(setDelay);
  199.         } catch (Exception e) { throw new Error("setDelay:: " + e.toString()); }
  200.  
  201.         try{
  202.             args = null;
  203.             MethodDescriptor stop = new MethodDescriptor(beanClass.getMethod("stop", args));
  204.  
  205.             connections = new java.util.Vector();
  206.             connection = new ConnectionDescriptor("input", "void", "",
  207.                                     "%name%.stop();",
  208.                                     conn.getString("stop"));
  209.             connections.addElement(connection);
  210.  
  211.             stop.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  212.             md.addElement(stop);
  213.         } catch (Exception e) { throw new Error("stop:: " + e.toString()); }
  214.  
  215.         try{
  216.             args = new Class[1];
  217.             args[0] = java.lang.Boolean.TYPE ;
  218.             MethodDescriptor setRepeat = new MethodDescriptor(beanClass.getMethod("setRepeat", args));
  219.  
  220.             connections = new java.util.Vector();
  221.             connection = new ConnectionDescriptor("input", "boolean", "",
  222.                                     "%name%.setRepeat(%arg%);",
  223.                                     conn.getString("setRepeat"));
  224.             connections.addElement(connection);
  225.  
  226.             setRepeat.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  227.             md.addElement(setRepeat);
  228.         } catch (Exception e) { throw new Error("setRepeat:: " + e.toString()); }
  229.  
  230.         try{
  231.             args = null;
  232.             MethodDescriptor isRepeat = new MethodDescriptor(beanClass.getMethod("isRepeat", args));
  233.  
  234.             connections = new java.util.Vector();
  235.             connection = new ConnectionDescriptor("output", "boolean", "",
  236.                                     "%name%.isRepeat()",
  237.                                     conn.getString("isRepeat"));
  238.             connections.addElement(connection);
  239.  
  240.             isRepeat.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  241.             md.addElement(isRepeat);
  242.         } catch (Exception e) { throw new Error("isRepeat:: " + e.toString()); }
  243.  
  244.         try{
  245.             args = null;
  246.             MethodDescriptor getString = new MethodDescriptor(beanClass.getMethod("getString", args));
  247.  
  248.             connections = new java.util.Vector();
  249.             connection = new ConnectionDescriptor("output", "String", "",
  250.                                     "%name%.getString()",
  251.                                     conn.getString("getString"));
  252.             connections.addElement(connection);
  253.  
  254.             getString.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  255.             md.addElement(getString);
  256.         } catch (Exception e) { throw new Error("getString:: " + e.toString()); }
  257.  
  258.         try{
  259.             args = null;
  260.             MethodDescriptor getDelay = new MethodDescriptor(beanClass.getMethod("getDelay", args));
  261.  
  262.             connections = new java.util.Vector();
  263.             connection = new ConnectionDescriptor("output", "int", "",
  264.                                     "%name%.getDelay()",
  265.                                     conn.getString("getDelay"));
  266.             connections.addElement(connection);
  267.  
  268.             getDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  269.             md.addElement(getDelay);
  270.         } catch (Exception e) { throw new Error("getDelay:: " + e.toString()); }
  271.  
  272.         try{
  273.             args = null;
  274.             MethodDescriptor clear = new MethodDescriptor(beanClass.getMethod("clear", args));
  275.  
  276.             connections = new java.util.Vector();
  277.             connection = new ConnectionDescriptor("input", "void", "",
  278.                                     "%name%.clear();",
  279.                                     conn.getString("clearStatusArea"));
  280.             connections.addElement(connection);
  281.  
  282.             clear.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  283.             md.addElement(clear);
  284.         } catch (Exception e) { throw new Error("clear:: " + e.toString()); }
  285.  
  286.         try{
  287.             args = null;
  288.             MethodDescriptor start = new MethodDescriptor(beanClass.getMethod("start", args));
  289.  
  290.             connections = new java.util.Vector();
  291.             connection = new ConnectionDescriptor("input", "void", "",
  292.                                     "%name%.start();",
  293.                                     conn.getString("start"));
  294.             connections.addElement(connection);
  295.  
  296.             start.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  297.             md.addElement(start);
  298.         } catch (Exception e) { throw new Error("start:: " + e.toString()); }
  299.  
  300.         try{
  301.             args = new Class[1];
  302.             args[0] = java.lang.Boolean.TYPE ;
  303.             MethodDescriptor setAutoStart = new MethodDescriptor(beanClass.getMethod("setAutoStart", args));
  304.  
  305.             connections = new java.util.Vector();
  306.             connection = new ConnectionDescriptor("input", "boolean", "",
  307.                                     "%name%.setAutoStart(%arg%);",
  308.                                     conn.getString("setAutoStart"));
  309.             connections.addElement(connection);
  310.  
  311.             setAutoStart.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  312.             md.addElement(setAutoStart);
  313.         } catch (Exception e) { throw new Error("setAutoStart:: " + e.toString()); }
  314.  
  315.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  316.         md.copyInto(rv);
  317.  
  318.         return rv;
  319.     }
  320.  
  321.     /**
  322.      * Returns descriptions of this bean's properties.
  323.      */
  324.     public PropertyDescriptor[] getPropertyDescriptors() {
  325.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  326.  
  327.         try{
  328.         PropertyDescriptor defProperty = new PropertyDescriptor("string", beanClass);
  329.         defProperty.setBound(true);
  330.         defProperty.setConstrained(true);
  331.         defProperty.setDisplayName(prop.getString("string"));
  332.  
  333.         PropertyDescriptor delay = new PropertyDescriptor("delay", beanClass);
  334.         delay.setBound(true);
  335.         delay.setConstrained(true);
  336.         delay.setDisplayName(prop.getString("delay"));
  337.  
  338.         PropertyDescriptor repeat = new PropertyDescriptor("repeat", beanClass);
  339.         repeat.setBound(true);
  340.         repeat.setConstrained(true);
  341.         repeat.setDisplayName(prop.getString("repeat"));
  342.  
  343.         PropertyDescriptor rightToLeft = new PropertyDescriptor("rightToLeft", beanClass);
  344.         rightToLeft.setBound(true);
  345.         rightToLeft.setConstrained(true);
  346.         rightToLeft.setDisplayName(prop.getString("rightToLeft"));
  347.  
  348.         PropertyDescriptor scrollClean = new PropertyDescriptor("scrollClean", beanClass);
  349.         scrollClean.setBound(true);
  350.         scrollClean.setConstrained(true);
  351.         scrollClean.setDisplayName(prop.getString("scrollClean"));
  352.  
  353.         PropertyDescriptor autoStart = new PropertyDescriptor("autoStart", beanClass);
  354.         autoStart.setBound(true);
  355.         autoStart.setConstrained(true);
  356.         autoStart.setDisplayName(prop.getString("autoStart"));
  357.  
  358.         PropertyDescriptor[] rv = {
  359.             defProperty,
  360.             delay,
  361.             repeat,
  362.             rightToLeft,
  363.             scrollClean,
  364.             autoStart};
  365.         return rv;
  366.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  367.     }
  368.  
  369.     /**
  370.      * Returns the index of the property expected to be changed most often by the designer.
  371.      */
  372.     public int getDefaultPropertyIndex() {
  373.         return 0;    //  the index for our default property is always 0
  374.     }
  375.  
  376.     private final static Class beanClass = StatusScroller.class;
  377.  
  378.     }    //  end of class StatusScrollerBeanInfo